def sorting (A):
    n=len(A)
    sortedA=sorted(A)#升序排序
    k=n//2
    A1=sortedA[:k]#前k个最小元素
    A2=sortedA[k:]
    return A1,A2
if __name__=="__main__":
    A=[1,3,4,3,6,8,3,2,74,2]
    A1,A2=sorting(A)
    print("A1:",A1)
    print("A2:",A2)
    print("|n1-n2|=",abs(len(A1)-len(A2)))
    s1,s2=sum(A1),sum(A2)
    print("s1=",s1,"s2=",s2,"|s1-s2|=",abs(s1-s2))
